<template>
    <div class="echart-chart">
        <div class="inside">
            <header><i class="el-icon-location-outline"></i> 市场健康指数</header>
            <div class="chartBox clearfix" style="min-height: 100px;">
                <aside v-show="!chartNoDataShow">
                    <p>市场健康指数：{{ isNull0(market_health_index) }} <span>（数值越高代表市场越健康）</span></p>
                    <p>售卖高于原价的房产在此区域的比例：{{ isNull0(sell_for_gain) }}</p>
                    <p>房屋价值指数：{{ isNull0_USD(zhvi) }}</p>
                    <p>环比：{{ isNull0(mom) }}</p>
                    <p>同比：{{ isNull0(yoy) }}</p>
                    <p>预测年变化：{{ isNull0(forecast_yoy_pct_change) }}</p>
                    <p>在售天数：{{ isNull0(days_on_market, '天') }}</p>
                    <p>房屋贷款坏账率：{{ isNull0(delinquency) }}</p>
                    <p>负资产房产所占比例：{{ isNull0(negative_equity) }}</p>
                </aside>
                <h4 ref="MarketHealthIndex_Zip_NoData" v-show="chartNoDataShow"></h4>
            </div>
            <p v-show="false">{{getzipcode}}</p>

        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                chartNoDataShow: false, //判断是否有无数据
                market_health_index: '', //市场健康指数
                sell_for_gain: '', //售卖高于原价的房产在此区域的比例
                zhvi: '', //房屋价值指数
                mom: '', //环比
                yoy: '', //同比
                forecast_yoy_pct_change: '', //预测年变化
                days_on_market: '', //在售天数
                delinquency: '', //犯罪
                negative_equity: '', //负资产

            }
        },
        computed: {
            //房源详情页图表使用——本房源所在邮zipcode
            getzipcode() {
                if(this.$store.getters.get_houseDetailsZipcode){
                    //获取市场健康指数数据
                    this.get_MarketHealthIndex_Zip();
                }
                return this.$store.getters.get_houseDetailsZipcode
            },

        },
        created() {
        },
        mounted() {
        },
        methods: {
            //获取市场健康指数数据
            get_MarketHealthIndex_Zip() {
                this.$get('/analysis/marketHealth/4/'+ this.$store.getters.get_houseDetailsZipcode).then(res => {
                    if (res.status == 0) {
                        if(res.data != null){
                            this.chartNoDataShow = false;
                            this.market_health_index = res.data.market_health_index ? res.data.market_health_index.toFixed(2) : 0;

                            this.sell_for_gain = res.data.sell_for_gain ? (res.data.sell_for_gain).toFixed(2) +'%' : 0;
                            this.zhvi = res.data.zhvi;

                            this.mom = res.data.mom ? (res.data.mom).toFixed(2) +'%' : 0;
                            this.yoy = res.data.yoy ? (res.data.yoy).toFixed(2) +'%' : 0;

                            this.forecast_yoy_pct_change = res.data.forecast_yoy_pct_change ? (res.data.forecast_yoy_pct_change * 100).toFixed(2) +'%' : 0;

                            this.days_on_market = res.data.days_on_market;
                            this.delinquency = res.data.delinquency ? (res.data.delinquency * 100).toFixed(2) +'%' : 0;
                            this.negative_equity = res.data.negative_equity ? (res.data.negative_equity * 100).toFixed(2) +'%' : 0;
                        }else{
                            this.chartNoDataShow = true;
                            this.$refs.MarketHealthIndex_Zip_NoData.innerText = '暂未查询到数据！';
                        }
                    } else {
                        this.chartNoDataShow = true;
                        this.$refs.MarketHealthIndex_Zip_NoData.innerText = res.msg;
                    }
                });
            },
        },
        components: {}
    }
</script>

<style scoped lang="less" type="text/less">
</style>
